package com.hotmocha.jclient;

import com.hotmocha.jclient.comm.R;
import com.hotmocha.jclient.model.net.BaseMessage;
import com.hotmocha.jclient.model.net.MemberList;
import com.hotmocha.jclient.model.net.Message;
import com.hotmocha.jclient.model.net.RespStatus;

public class ActionsManager {
    private ChatClientMain chatClintMain;
    private BaseMessage baseMessage;

    public ActionsManager(ChatClientMain chatClintMain) {
        this.chatClintMain = chatClintMain;
    }

    public void receiveMessage(BaseMessage baseMessage) {
        this.baseMessage = baseMessage;
        switch(this.baseMessage.MessageType()){
            case R.MSG_TYPE_MEMBER_LIST:
                MemberList memberList = (MemberList)this.baseMessage;
                this.chatClintMain.getUserList(memberList);
                break;
            case R.MSG_TYPE_COMM_MSG:
                Message message = (Message)this.baseMessage;
                this.chatClintMain.getChatMessage(message);
                break;
            case R.MSG_TYPE_RESPSTATUS:
            	RespStatus status = (RespStatus)this.baseMessage;
            	this.chatClintMain.getRespStatus(status);
            case R.MSG_TYPE_UNKNOW:
                break;
        }
    }

    public void connected() {
        this.chatClintMain.connected();
    }

    public void disconnected() {
        this.chatClintMain.disconnected();
    }
}